package com.zhika.zishi.customview;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.zhika.zishi.util.LogUtil;

/**
 * Created by shi-02 on 2015/4/15.
 */
public class CustomeViewPager extends ViewPager {

    private float downX;

    private float moveX;

    private float upX;

    private boolean isMoveFirst = true;

    private final String TAG = "CustomeViewPager";

    public CustomeViewPager(Context context) {
        this(context, null);
    }

    public CustomeViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
       switch (ev.getAction()){
           case MotionEvent.ACTION_DOWN:
               downX = ev.getRawX();
               LogUtil.e(TAG,"downX="+downX);
               break;
           case MotionEvent.ACTION_MOVE:
               if (isMoveFirst){
                   moveX = ev.getRawX();
                   LogUtil.e(TAG,"move="+moveX);
                   isMoveFirst = false;
               }
               break;
           case MotionEvent.ACTION_UP:
               isMoveFirst = true;
               upX = ev.getRawX();
               LogUtil.e(TAG,"upX = "+upX);
               break;
           default:
               break;
       }
        return super.onTouchEvent(ev);
    }
}
